/* Map XPT2046 input to ILI9341 320x240 raster */
#include "SPI.h"
#include <XPT2046_Touchscreen.h> /* https://github.com/PaulStoffregen/XPT2046_Touchscreen */

// #define TOUCH_CS_PIN       5
// #define TOUCH_IRQ_PIN      21
#define TOUCH_CS_PIN       14
#define TOUCH_IRQ_PIN      27


XPT2046_Touchscreen touch( TOUCH_CS_PIN, TOUCH_IRQ_PIN );

void setup() {
    pinMode(12,OUTPUT);
    digitalWrite(12,HIGH);
  Serial.begin( 115200 );
  touch.begin();
  Serial.println( "Touch screen ready." );
  touch.setRotation(1);
}

TS_Point rawLocation;

void loop() {
    while ( touch.touched() )
    {
        rawLocation = touch.getPoint();
        Serial.print("x = ");
        Serial.print(rawLocation.x);
        Serial.print(", y = ");
        Serial.print(rawLocation.y);
        Serial.print(", z = ");
        Serial.println(rawLocation.z); 
        delay(50);  
    }
}
